/*
============================================================================
 Name        : BlockInfoText.h
 Author      : 
 Version     :
 Copyright   : 
 Description : CBlockInfoText declaration
============================================================================
*/

#ifndef BlockInfoText_H
#define BlockInfoText_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include "Block.h"
#include "BlockInfoTitle.h"
#include "Flickable.h"
// CLASS DECLARATION

const TInt KMenuIdNextMessage = 100;
const TInt KMenuIdPreviousMessage = 101;

/**
*  CBlockInfoText
* 
*/
class CBlockInfoText : public CBlock, public MFlickableCallback
{
public:
	~CBlockInfoText();

	static CBlockInfoText* NewL(CBaseBlock* bsBack, TBool aNeedTitle = EFalse);

	static CBlockInfoText* NewLC(CBaseBlock* bsBack, TBool aNeedTitle = EFalse);

private:
	CBlockInfoText(CBaseBlock* bsBack, TBool aNeedTitle = ETrue);

	void ConstructL();

public:
	// from MFlickableCallback
	virtual TPoint ScrollOffset() const;

	virtual void SetScrollOffset(const TPoint& aOffset);

public:
	//from CBlock
	void OnDraw(CFbsBitGc& g)const;

	void OnKeyDown(TInt keyCode);

	void InitData();

	TBool OnMenuEvent(TInt menuId);

	void InitPopMenu();

	/*TBool ReadData(const TDesC8& aData);

	void WriteData(TDes8& aBuf);

	TInt GetDataLength();

	TInt16 GetDataType();*/

	void ChangeScrollPos(TInt nPos);

	void SizeChanged();

	void OnMouseDown(const TPoint& aPt);

	void OnMouseMove(const TPoint& aPt);

	void OnMouseUp(const TPoint& aPt);
	
	void ChangeFocus(TBool aFoucs, const TInt& keyCode);
	
	TBool SetReqURL(const TDesC8& urlReq);

	TBool GetHYURL(TDes8& aUri);

	TBool ParseJSONArray(const TDesC8& aJson);
	
protected:
	void AddTabs();
	
	void BeforeDraw(CFbsBitGc& g) const;

public: // from MTabbarObserver
	void HandleTabbarCommand(TInt aCommand);

public:
	TInfo m_info;
	HBufC* m_strText;
	HBufC* m_strTextTitle;
	TBool m_isFromBengBeng;
	TInt m_nBengBengMessage;
	TInt m_nTotalBengBengMessage;
	TBool m_needTitle;

private:
	CDesCArray* m_vTitle;
	CDesCArray* m_vText;
	CBengBengDbMgr* iBengBengDbMgr;

	TBuf<32> m_bufDownloading;
	TBuf<32> m_bufNoInfo;
	
	TBuf8<128>	m_BufURL;

private:
	TInt iOffset;
	TInt iHeight;
	CFlickable* iFlickable;
	TRect iTextRect;
	TInt iTotalLines;

	mutable TInt iStartItem;
	mutable TInt iEndItem;
};

#endif // BlockInfoText_H
